//
//  EntertainmentTableViewCell.m
//  WangI
//
//  Created by dllo on 15/11/24.
//  Copyright © 2015年 WJN. All rights reserved.
//

#import "EntertainmentTableViewCell.h"

@implementation EntertainmentTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.leftImage];
        [self addSubview:self.titleLabel];
        [self addSubview:self.detailLabel];
        
    }
    return self;
}


- (void)setEntertainmentModel:(EntertainmentModel *)entertainmentModel {
    if (_entertainmentModel != entertainmentModel) {
        [_entertainmentModel release];
        _entertainmentModel = [entertainmentModel retain];
    }
    
    [self.leftImage sd_setImageWithURL:[NSURL URLWithString:_entertainmentModel.imgsrc]];
    self.titleLabel.text = _entertainmentModel.title;
    self.detailLabel.text = _entertainmentModel.digest;
}

- (void)layoutSubviews {
    self.leftImage.frame = CGRectMake(5, 5, self.frame.size.width / 5, self.frame.size.height - 10);
    self.titleLabel.frame = CGRectMake(self.leftImage.right + 5, 5, self.width - self.leftImage.width - 10, self.leftImage.height / 3);
    self.detailLabel.frame = CGRectMake(self.titleLabel.left, self.titleLabel.bottom, self.titleLabel.width, self.leftImage.height - self.titleLabel.height);
}

- (UIImageView *)leftImage {
    if (!_leftImage) {
        self.leftImage = [[UIImageView alloc] initWithFrame:CGRectZero];
    }
    return _leftImage;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    }
    return _titleLabel;
}

- (UILabel *)detailLabel {
    if (!_detailLabel) {
        self.detailLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _detailLabel.font = [UIFont systemFontOfSize:13];
        _detailLabel.numberOfLines = 0;
    }
    return _detailLabel;
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
